#include "Tipsrad.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;

bool Tipsrad::oddsSet = false;
int Tipsrad::home[13] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int Tipsrad::draw[13] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int Tipsrad::away[13] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

Tipsrad::Tipsrad()
{
	getOdds();
	srand(time(NULL));
}


Tipsrad::~Tipsrad()
{
}

void Tipsrad::getOdds()
{
	if (!oddsSet){
		cout << "ENTER PROBABILITES FOR MATCH RESULSTS" << endl;
		for (int i = 0; i < 13; i++){
			bool oddsOk = false;
			while (!oddsOk){
				cout << "Match number " << setw(3) << left << i + 1 << "(1,X,2 %): ";
				cin >> home[i] >> draw[i] >> away[i];
				if ((home[i] + draw[i] + away[i]) > 100){
					cout << home[i] << " + " << draw[i] << " + " << away[i] << " is greater than 100%, please eneter some new values.." << endl;
				}
				else if ((home[i] + draw[i] + away[i]) < 100){
					cout << home[i] << " + " << draw[i] << " + " << away[i] << " is less than 100%, please enter some new values.." << endl;
				}
				else{
					oddsOk = true;
				}
			}
		}
		cout << endl;
		oddsSet = true;
	}
}

void Tipsrad::getResult()
{
	for (int i = 0; i < 13; i++){
		int result = (rand() % 100) + 1;
		if (result <= home[i]){
			cout << "1 ";
		}
		else if (result <= (home[i] + away[i])){
			cout << "2 ";
		}
		else{
			cout << "X ";
		}
	}
	cout << endl;
}